package com.twu.biblioteca;

import java.util.ArrayList;

/**
 * Created by jrocha on 10/2/14.
 */
public class Login {
    public Login(ArrayList<User> users) {
        this.users = users;
    }

    public boolean checkCredentials(String userLogin, String userPassword) {
        boolean credentialsMatch = false;
        for(int count = 0; count < users.size(); ++count){
            User user = users.get(count);
            String login = user.getLibraryNumber();
            String password = user.getPassword();

            if (login.equals(userLogin) && password.equals(userPassword)) {
                credentialsMatch = true;
                logedUser = user;
            }
        }

        return credentialsMatch;
    }

    public User getCurrentUser() {
        return logedUser;
    }

    private ArrayList<User> users;
    private User logedUser;


}
